home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / applic / backup / 8mmbackup.shar.Z / 8mmbackup.shar / fnFilter.awk < prev    next >
Encoding:
AWK Script  |  1989-11-19  |  856 b   |  29 lines

  1. #!/bin/awk
  2. #
  3. # Suggested usage: set capacity=`... | awk -f fnFilter.awk argFile=<filename>`
  4. #
  5. # This is a fundamental component of the 8mmbackup system.
  6. #
  7. # This awk filter takes 'ls -gild .<path>' (and 'find -ls .<path>') format (as
  8. # of bsd 4.2 Unix, Sun OS 3.5) from stdin and prints the filenames into
  9. # designated 'argFile', returning total disk capacity encompassed by the files
  10. # as the value.  Note that the leading '.' on the path argument is critical.
  11. #
  12. # Specific provisions have been made for names with embedded blanks and
  13. # 'ls -gild' symbolic-link format. 
  14. #
  15.  
  16. BEGIN {tally = 0}
  17.  
  18. # Symbolic links:
  19. / -> / { beg=index($0,"./");
  20.      print substr($0,beg,index($0," ->")-beg) > argFile }
  21.  
  22. # Non-symbolic links:
  23. ! / -> / { beg=index($0,"./"); print substr($0,beg,length-beg+1) > argFile }
  24.  
  25. # Accumulate tally
  26. {tally = tally + $7}
  27.  
  28. END {print tally}
  29.